class Add:
    @classmethod
    def info(selt):
        # 1.导入pymysql
        import pymysql

        # 2.创建链接对象
        conn = pymysql.connect(user='root', password='root', database='advanced', charset='utf8')
        # 3.获取游标对象
        cursor = conn.cursor()
        # 4.执行sql语句
        try:
            for i in range(5):
                info1 = input('输入插入内容标题1：')
                info2 = input('输入插入内容作者1：')
                info3 = input('输入插入内容内容1：')
                sql = f'insert into journalism(title, author, content) values({info1},{info2},{info3})'
                rows = cursor.execute(sql)
                print(rows)
        except Exception as e:
            conn.rollback()
            print(e)
        else:
            conn.commit()
        # 5.提交或者回滚
        # 6.7关闭

        cursor.close()
        conn.close()
Add.info()